package com.cyz.web.app.function.stream;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@ToString
@Getter
@Setter
@AllArgsConstructor
public class Author {

    private String name;
    private LocalDate birth;
    private List<Book> books;

    public static List<Author> getAuthors() {


        Book b11 = new Book("老人与海","爱情,战争", BigDecimal.valueOf(423.1));
        Book b12 = new Book("太阳照常升起","爱情,战争", BigDecimal.valueOf(423.1));
        Book b13 = new Book("永别了,武器","爱情,战争", BigDecimal.valueOf(223.1));
        List<Book> books1 = Arrays.asList(b11, b12, b13);
        Author a1 = new Author("海明威", LocalDate.of(1899, 7, 21), books1);

        Book b21 = new Book("亨利第三及其宫廷","爱情,战争", BigDecimal.valueOf(423.1));
        Book b22 = new Book("基督山伯爵","爱情,战争", BigDecimal.valueOf(4223.1));
        Book b23 = new Book("三和火枪手","爱情,战争", BigDecimal.valueOf(123.1));
        List<Book> books2 = Arrays.asList(b21, b22, b23);
        Author a2 = new Author("大仲马", LocalDate.of(1802, 6, 24), books2);

        Book b31 = new Book("复活","爱情,战争", BigDecimal.valueOf(423.1));
        Book b32 = new Book("战争与和平","宗教,战争", BigDecimal.valueOf(423.1));
        Book b33 = new Book("安娜·卡列尼娜","爱情,战争", BigDecimal.valueOf(423.1));
        List<Book> books3 = Arrays.asList(b31, b32, b33);
        Author a3 = new Author("列夫·托尔斯泰", LocalDate.of(1828, 9, 9), books3);

        Book b41 = new Book("吉檀迦利","爱情,悬疑", BigDecimal.valueOf(423.1));
        Book b42 = new Book("飞鸟集","爱情,战争", BigDecimal.valueOf(123.1));
        Book b43 = new Book("四个人","激情,战争", BigDecimal.valueOf(423.1));
        List<Book> books4 = Arrays.asList(b41, b42, b43);
        Author a4 = new Author("泰戈尔", LocalDate.of(1861, 5, 7), books4);
        List<Author> authors = Arrays.asList(a1, a2, a3, a4);

        return authors;
    }


}

@ToString
@Setter
@Getter
@AllArgsConstructor
class Book {
    private String name;
    private String category;
    private BigDecimal price;

}
